package com.ideaplugin.datamanager.model.response;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * Created on 2022/3/21.
 *
 * @author zhaojb
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserTableDataVo {

    @Schema(description = "字段name")
    private String columnName;
    @Schema(description = "字段code")
    private String columnCode;
    @Schema(description = "值")
    private Object value;

    public Object getValue() {
        if (value instanceof Date) {
            return DateUtil.formatDateTime((Date) value);
        }
        if (value instanceof LocalDateTime) {
            return LocalDateTimeUtil.formatNormal((LocalDateTime) value);
        }
        return value;
    }
}
